<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.11.0"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>cppMISC: include/bufferBlock.hpp 源文件</title>
<link href="../../tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../jquery.js"></script>
<script type="text/javascript" src="../../dynsections.js"></script>
<script type="text/javascript" src="../../clipboard.js"></script>
<link href="../../navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../resize.js"></script>
<script type="text/javascript" src="../../cookie.js"></script>
<link href="../../search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../search/searchdata.js"></script>
<script type="text/javascript" src="../../search/search.js"></script>
<script type="text/javascript" src="../../darkmode_toggle.js"></script>
<link href="../../doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr id="projectrow">
  <td id="projectalign">
   <div id="projectname">cppMISC<span id="projectnumber">&#160;v1.1</span>
   </div>
   <div id="projectbrief">cppMisc 文档系统</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- 制作者 Doxygen 1.11.0 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "../../search/",'.html');
/* @license-end */
</script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() { codefold.init(1); });
/* @license-end */
</script>
<script type="text/javascript" src="../../menudata.js"></script>
<script type="text/javascript" src="../../menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
  initMenu('../../',true,false,'search.php','搜索',false);
  $(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function(){ initResizable(false); });
/* @license-end */
</script>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">载入中...</div>
<div class="SRStatus" id="Searching">搜索中...</div>
<div class="SRStatus" id="NoMatches">未找到</div>
</div>
</div>
</div>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="../../dir_d44c64559bbebec7f509842c48db8b23.html">include</a></li>  </ul>
</div>
</div><!-- top -->
<div id="doc-content">
<div class="header">
  <div class="headertitle"><div class="title">bufferBlock.hpp</div></div>
</div><!--header-->
<div class="contents">
<a href="../../dd/da6/buffer_block_8hpp.html">浏览该文件的文档.</a><div class="fragment"><div class="line"><a id="l00001" name="l00001"></a><span class="lineno">    1</span> </div>
<div class="line"><a id="l00008" name="l00008"></a><span class="lineno">    8</span><span class="preprocessor">#pragma once</span></div>
<div class="line"><a id="l00009" name="l00009"></a><span class="lineno">    9</span> </div>
<div class="line"><a id="l00010" name="l00010"></a><span class="lineno">   10</span><span class="preprocessor">#include &lt;memory&gt;</span></div>
<div class="line"><a id="l00011" name="l00011"></a><span class="lineno">   11</span><span class="preprocessor">#include &lt;string&gt;</span></div>
<div class="line"><a id="l00012" name="l00012"></a><span class="lineno">   12</span> </div>
<div class="line"><a id="l00013" name="l00013"></a><span class="lineno">   13</span><span class="preprocessor">#include &quot;<a class="code" href="../../d0/d5c/malloc_shared_ptr_8hpp.html">mallocSharedPtr.hpp</a>&quot;</span></div>
<div class="line"><a id="l00014" name="l00014"></a><span class="lineno">   14</span><span class="preprocessor">#include &quot;<a class="code" href="../../de/d6d/singleton_8hpp.html">designM/singleton.hpp</a>&quot;</span></div>
<div class="line"><a id="l00015" name="l00015"></a><span class="lineno">   15</span><span class="keyword">namespace </span><a class="code hl_namespace" href="../../df/d8d/namespacewheels.html">wheels</a></div>
<div class="line"><a id="l00016" name="l00016"></a><span class="lineno">   16</span>{</div>
<div class="foldopen" id="foldopen00017" data-start="{" data-end="};">
<div class="line"><a id="l00017" name="l00017"></a><span class="lineno"><a class="line" href="../../d5/d36/classwheels_1_1buff.html">   17</a></span>    <span class="keyword">class </span><a class="code hl_class" href="../../d5/d36/classwheels_1_1buff.html">buff</a> : <span class="keyword">public</span> <a class="code hl_class" href="../../de/d44/classwheels_1_1dm_1_1singleton.html">wheels::dm::singleton</a>&lt; buff &gt;</div>
<div class="line"><a id="l00018" name="l00018"></a><span class="lineno">   18</span>    {</div>
<div class="line"><a id="l00019" name="l00019"></a><span class="lineno">   19</span>    <span class="keyword">public</span>:</div>
<div class="line"><a id="l00020" name="l00020"></a><span class="lineno"><a class="line" href="../../d5/d36/classwheels_1_1buff.html#a6503c646eb1b9b523b4bab4fc3929805">   20</a></span>        <span class="keyword">using </span><a class="code hl_typedef" href="../../d5/d36/classwheels_1_1buff.html#a6503c646eb1b9b523b4bab4fc3929805">iterator</a> = <span class="keywordtype">char</span> *;</div>
<div class="line"><a id="l00021" name="l00021"></a><span class="lineno">   21</span>    <span class="keyword">private</span>:</div>
<div class="line"><a id="l00022" name="l00022"></a><span class="lineno">   22</span>        <a class="code hl_class" href="../../da/d39/classwheels_1_1malloc_shared_ptr.html">wheels::mallocSharedPtr&lt; char &gt;</a>     __pt_data;</div>
<div class="line"><a id="l00023" name="l00023"></a><span class="lineno">   23</span>        <span class="comment">// 当前数据写入点。当写入数据的总长度会大于缓冲区长度会造成写入失败</span></div>
<div class="line"><a id="l00024" name="l00024"></a><span class="lineno">   24</span>        <span class="keywordtype">size_t</span>  __m_curr_pos;</div>
<div class="line"><a id="l00025" name="l00025"></a><span class="lineno">   25</span>        <span class="keywordtype">size_t</span>  __m_size;</div>
<div class="line"><a id="l00026" name="l00026"></a><span class="lineno">   26</span>    <span class="keyword">private</span>:</div>
<div class="line"><a id="l00027" name="l00027"></a><span class="lineno">   27</span> </div>
<div class="line"><a id="l00028" name="l00028"></a><span class="lineno">   28</span>    <span class="keyword">public</span>:</div>
<div class="line"><a id="l00029" name="l00029"></a><span class="lineno">   29</span>        <a class="code hl_function" href="../../d5/d36/classwheels_1_1buff.html#aeea7382f5dbe94bd7bfae2a8f3b2908b">buff</a>();</div>
<div class="line"><a id="l00030" name="l00030"></a><span class="lineno"><a class="line" href="../../d5/d36/classwheels_1_1buff.html#a94aa05af107e6b5906f269e7ef53609e">   30</a></span>        <span class="keyword">virtual</span> <a class="code hl_function" href="../../d5/d36/classwheels_1_1buff.html#a94aa05af107e6b5906f269e7ef53609e">~buff</a>(){}</div>
<div class="line"><a id="l00036" name="l00036"></a><span class="lineno">   36</span>        <span class="keywordtype">bool</span> <a class="code hl_function" href="../../d5/d36/classwheels_1_1buff.html#ac76d02cb8a8df2065a8d96840db8f576">toString</a>( std::string&amp; rst );</div>
<div class="line"><a id="l00037" name="l00037"></a><span class="lineno">   37</span> </div>
<div class="line"><a id="l00038" name="l00038"></a><span class="lineno"><a class="line" href="../../d5/d36/classwheels_1_1buff.html#a28fa99c3986c5015445b03278583ee16">   38</a></span>        <a class="code hl_typedef" href="../../d5/d36/classwheels_1_1buff.html#a6503c646eb1b9b523b4bab4fc3929805">iterator</a> <a class="code hl_function" href="../../d5/d36/classwheels_1_1buff.html#a28fa99c3986c5015445b03278583ee16">begin</a>(){ <span class="keywordflow">return</span> __pt_data.get(); }</div>
<div class="line"><a id="l00039" name="l00039"></a><span class="lineno"><a class="line" href="../../d5/d36/classwheels_1_1buff.html#a6e3ce9942dd85782b8169fd81abb41ca">   39</a></span>        <a class="code hl_typedef" href="../../d5/d36/classwheels_1_1buff.html#a6503c646eb1b9b523b4bab4fc3929805">iterator</a> <a class="code hl_function" href="../../d5/d36/classwheels_1_1buff.html#a6e3ce9942dd85782b8169fd81abb41ca">end</a>(){ <span class="keywordflow">return</span> __pt_data.get() + __m_curr_pos + 1; }</div>
<div class="line"><a id="l00040" name="l00040"></a><span class="lineno">   40</span> </div>
<div class="line"><a id="l00041" name="l00041"></a><span class="lineno"><a class="line" href="../../d5/d36/classwheels_1_1buff.html#aae19c93f1b14fe408bcc07cea57e5ad9">   41</a></span>        <span class="keywordtype">char</span> * <a class="code hl_function" href="../../d5/d36/classwheels_1_1buff.html#aae19c93f1b14fe408bcc07cea57e5ad9">buffer</a>(){ <span class="keywordflow">return</span> __pt_data.get(); }</div>
<div class="line"><a id="l00042" name="l00042"></a><span class="lineno"><a class="line" href="../../d5/d36/classwheels_1_1buff.html#add5a83b6176c87a0c8c850ea696f71fa">   42</a></span>        <span class="keywordtype">size_t</span> <a class="code hl_function" href="../../d5/d36/classwheels_1_1buff.html#add5a83b6176c87a0c8c850ea696f71fa">dataSize</a>(){ <span class="keywordflow">return</span> __m_curr_pos; }</div>
<div class="foldopen" id="foldopen00043" data-start="{" data-end="}">
<div class="line"><a id="l00043" name="l00043"></a><span class="lineno"><a class="line" href="../../d5/d36/classwheels_1_1buff.html#ad15bf2ba9b9363fde0989687e9af67a2">   43</a></span>        <span class="keywordtype">void</span> <a class="code hl_function" href="../../d5/d36/classwheels_1_1buff.html#ad15bf2ba9b9363fde0989687e9af67a2">clear</a>(){</div>
<div class="line"><a id="l00044" name="l00044"></a><span class="lineno">   44</span>            __m_curr_pos = 0;</div>
<div class="line"><a id="l00045" name="l00045"></a><span class="lineno">   45</span>            __pt_data.get()[0]=<span class="charliteral">&#39;\0&#39;</span>;</div>
<div class="line"><a id="l00046" name="l00046"></a><span class="lineno">   46</span>        }</div>
</div>
<div class="line"><a id="l00054" name="l00054"></a><span class="lineno">   54</span>        <span class="keywordtype">bool</span> <a class="code hl_function" href="../../d5/d36/classwheels_1_1buff.html#a485b97a14184a5a3f0d62269c102b08e">write</a>( <span class="keyword">const</span> <span class="keywordtype">char</span> * data , <span class="keywordtype">size_t</span> len , <span class="keywordtype">bool</span> clearPos = <span class="keyword">true</span> );</div>
<div class="line"><a id="l00055" name="l00055"></a><span class="lineno">   55</span>        <span class="keywordtype">bool</span> <a class="code hl_function" href="../../d5/d36/classwheels_1_1buff.html#a485b97a14184a5a3f0d62269c102b08e">write</a>( <span class="keyword">const</span> std::string&amp; data , <span class="keywordtype">bool</span> clearPos = <span class="keyword">true</span> );</div>
<div class="foldopen" id="foldopen00061" data-start="{" data-end="}">
<div class="line"><a id="l00061" name="l00061"></a><span class="lineno"><a class="line" href="../../d5/d36/classwheels_1_1buff.html#a515b0157323d003d74bbc7bc3435ac10">   61</a></span>        <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code hl_function" href="../../d5/d36/classwheels_1_1buff.html#a515b0157323d003d74bbc7bc3435ac10">resize</a>( <span class="keywordtype">size_t</span> s )</div>
<div class="line"><a id="l00062" name="l00062"></a><span class="lineno">   62</span>            {</div>
<div class="line"><a id="l00063" name="l00063"></a><span class="lineno">   63</span>                <span class="keywordflow">try</span>{</div>
<div class="line"><a id="l00064" name="l00064"></a><span class="lineno">   64</span>                    __pt_data.<a class="code hl_function" href="../../da/d39/classwheels_1_1malloc_shared_ptr.html#aa70d2770b69c634fbe8a01351ffdb768">resize</a>( s );</div>
<div class="line"><a id="l00065" name="l00065"></a><span class="lineno">   65</span> </div>
<div class="line"><a id="l00066" name="l00066"></a><span class="lineno">   66</span>                }<span class="keywordflow">catch</span>( std::bad_alloc&amp; e ){</div>
<div class="line"><a id="l00067" name="l00067"></a><span class="lineno">   67</span>                    <span class="keywordflow">return</span> <span class="keyword">false</span>;</div>
<div class="line"><a id="l00068" name="l00068"></a><span class="lineno">   68</span>                }</div>
<div class="line"><a id="l00069" name="l00069"></a><span class="lineno">   69</span> </div>
<div class="line"><a id="l00070" name="l00070"></a><span class="lineno">   70</span>                <span class="keywordflow">return</span> <span class="keyword">true</span>;</div>
<div class="line"><a id="l00071" name="l00071"></a><span class="lineno">   71</span>            }</div>
</div>
<div class="line"><a id="l00072" name="l00072"></a><span class="lineno"><a class="line" href="../../d5/d36/classwheels_1_1buff.html#a231c3e93e227bc73fd900acfcc6cf646">   72</a></span>        <span class="keyword">inline</span> <span class="keywordtype">size_t</span> <a class="code hl_function" href="../../d5/d36/classwheels_1_1buff.html#a231c3e93e227bc73fd900acfcc6cf646">size</a>(){ <span class="keywordflow">return</span> __m_size; }</div>
<div class="line"><a id="l00073" name="l00073"></a><span class="lineno">   73</span>    };</div>
</div>
<div class="line"><a id="l00074" name="l00074"></a><span class="lineno">   74</span> </div>
<div class="line"><a id="l00075" name="l00075"></a><span class="lineno">   75</span>}</div>
<div class="ttc" id="aclasswheels_1_1buff_html"><div class="ttname"><a href="../../d5/d36/classwheels_1_1buff.html">wheels::buff</a></div><div class="ttdef"><b>定义</b> <a href="#l00017">bufferBlock.hpp:18</a></div></div>
<div class="ttc" id="aclasswheels_1_1buff_html_a231c3e93e227bc73fd900acfcc6cf646"><div class="ttname"><a href="../../d5/d36/classwheels_1_1buff.html#a231c3e93e227bc73fd900acfcc6cf646">wheels::buff::size</a></div><div class="ttdeci">size_t size()</div><div class="ttdef"><b>定义</b> <a href="#l00072">bufferBlock.hpp:72</a></div></div>
<div class="ttc" id="aclasswheels_1_1buff_html_a28fa99c3986c5015445b03278583ee16"><div class="ttname"><a href="../../d5/d36/classwheels_1_1buff.html#a28fa99c3986c5015445b03278583ee16">wheels::buff::begin</a></div><div class="ttdeci">iterator begin()</div><div class="ttdef"><b>定义</b> <a href="#l00038">bufferBlock.hpp:38</a></div></div>
<div class="ttc" id="aclasswheels_1_1buff_html_a485b97a14184a5a3f0d62269c102b08e"><div class="ttname"><a href="../../d5/d36/classwheels_1_1buff.html#a485b97a14184a5a3f0d62269c102b08e">wheels::buff::write</a></div><div class="ttdeci">bool write(const char *data, size_t len, bool clearPos=true)</div><div class="ttdoc">buff中写入数据内容</div><div class="ttdef"><b>定义</b> <a href="../../d7/dac/buffer_block_8cpp_source.html#l00021">bufferBlock.cpp:21</a></div></div>
<div class="ttc" id="aclasswheels_1_1buff_html_a515b0157323d003d74bbc7bc3435ac10"><div class="ttname"><a href="../../d5/d36/classwheels_1_1buff.html#a515b0157323d003d74bbc7bc3435ac10">wheels::buff::resize</a></div><div class="ttdeci">bool resize(size_t s)</div><div class="ttdoc">调整缓冲区大小</div><div class="ttdef"><b>定义</b> <a href="#l00061">bufferBlock.hpp:61</a></div></div>
<div class="ttc" id="aclasswheels_1_1buff_html_a6503c646eb1b9b523b4bab4fc3929805"><div class="ttname"><a href="../../d5/d36/classwheels_1_1buff.html#a6503c646eb1b9b523b4bab4fc3929805">wheels::buff::iterator</a></div><div class="ttdeci">char * iterator</div><div class="ttdef"><b>定义</b> <a href="#l00020">bufferBlock.hpp:20</a></div></div>
<div class="ttc" id="aclasswheels_1_1buff_html_a6e3ce9942dd85782b8169fd81abb41ca"><div class="ttname"><a href="../../d5/d36/classwheels_1_1buff.html#a6e3ce9942dd85782b8169fd81abb41ca">wheels::buff::end</a></div><div class="ttdeci">iterator end()</div><div class="ttdef"><b>定义</b> <a href="#l00039">bufferBlock.hpp:39</a></div></div>
<div class="ttc" id="aclasswheels_1_1buff_html_a94aa05af107e6b5906f269e7ef53609e"><div class="ttname"><a href="../../d5/d36/classwheels_1_1buff.html#a94aa05af107e6b5906f269e7ef53609e">wheels::buff::~buff</a></div><div class="ttdeci">virtual ~buff()</div><div class="ttdef"><b>定义</b> <a href="#l00030">bufferBlock.hpp:30</a></div></div>
<div class="ttc" id="aclasswheels_1_1buff_html_aae19c93f1b14fe408bcc07cea57e5ad9"><div class="ttname"><a href="../../d5/d36/classwheels_1_1buff.html#aae19c93f1b14fe408bcc07cea57e5ad9">wheels::buff::buffer</a></div><div class="ttdeci">char * buffer()</div><div class="ttdef"><b>定义</b> <a href="#l00041">bufferBlock.hpp:41</a></div></div>
<div class="ttc" id="aclasswheels_1_1buff_html_ac76d02cb8a8df2065a8d96840db8f576"><div class="ttname"><a href="../../d5/d36/classwheels_1_1buff.html#ac76d02cb8a8df2065a8d96840db8f576">wheels::buff::toString</a></div><div class="ttdeci">bool toString(std::string &amp;rst)</div><div class="ttdoc">将结果转换成标准字符串。</div><div class="ttdef"><b>定义</b> <a href="../../d7/dac/buffer_block_8cpp_source.html#l00011">bufferBlock.cpp:11</a></div></div>
<div class="ttc" id="aclasswheels_1_1buff_html_ad15bf2ba9b9363fde0989687e9af67a2"><div class="ttname"><a href="../../d5/d36/classwheels_1_1buff.html#ad15bf2ba9b9363fde0989687e9af67a2">wheels::buff::clear</a></div><div class="ttdeci">void clear()</div><div class="ttdef"><b>定义</b> <a href="#l00043">bufferBlock.hpp:43</a></div></div>
<div class="ttc" id="aclasswheels_1_1buff_html_add5a83b6176c87a0c8c850ea696f71fa"><div class="ttname"><a href="../../d5/d36/classwheels_1_1buff.html#add5a83b6176c87a0c8c850ea696f71fa">wheels::buff::dataSize</a></div><div class="ttdeci">size_t dataSize()</div><div class="ttdef"><b>定义</b> <a href="#l00042">bufferBlock.hpp:42</a></div></div>
<div class="ttc" id="aclasswheels_1_1buff_html_aeea7382f5dbe94bd7bfae2a8f3b2908b"><div class="ttname"><a href="../../d5/d36/classwheels_1_1buff.html#aeea7382f5dbe94bd7bfae2a8f3b2908b">wheels::buff::buff</a></div><div class="ttdeci">buff()</div><div class="ttdef"><b>定义</b> <a href="../../d7/dac/buffer_block_8cpp_source.html#l00009">bufferBlock.cpp:9</a></div></div>
<div class="ttc" id="aclasswheels_1_1dm_1_1singleton_html"><div class="ttname"><a href="../../de/d44/classwheels_1_1dm_1_1singleton.html">wheels::dm::singleton</a></div><div class="ttdef"><b>定义</b> <a href="../../de/d6d/singleton_8hpp_source.html#l00019">singleton.hpp:20</a></div></div>
<div class="ttc" id="aclasswheels_1_1malloc_shared_ptr_html"><div class="ttname"><a href="../../da/d39/classwheels_1_1malloc_shared_ptr.html">wheels::mallocSharedPtr&lt; char &gt;</a></div></div>
<div class="ttc" id="aclasswheels_1_1malloc_shared_ptr_html_aa70d2770b69c634fbe8a01351ffdb768"><div class="ttname"><a href="../../da/d39/classwheels_1_1malloc_shared_ptr.html#aa70d2770b69c634fbe8a01351ffdb768">wheels::mallocSharedPtr::resize</a></div><div class="ttdeci">void resize(size_t s)</div><div class="ttdoc">这个方法会放弃旧的数据内容</div><div class="ttdef"><b>定义</b> <a href="../../d0/d5c/malloc_shared_ptr_8hpp_source.html#l00147">mallocSharedPtr.hpp:147</a></div></div>
<div class="ttc" id="amalloc_shared_ptr_8hpp_html"><div class="ttname"><a href="../../d0/d5c/malloc_shared_ptr_8hpp.html">mallocSharedPtr.hpp</a></div></div>
<div class="ttc" id="anamespacewheels_html"><div class="ttname"><a href="../../df/d8d/namespacewheels.html">wheels</a></div><div class="ttdoc">堆栈信息读取和保存记录</div><div class="ttdef"><b>定义</b> <a href="../../d3/df7/ary__str_8hpp_source.html#l00006">ary_str.hpp:7</a></div></div>
<div class="ttc" id="asingleton_8hpp_html"><div class="ttname"><a href="../../de/d6d/singleton_8hpp.html">singleton.hpp</a></div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
制作者&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="../../doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.11.0
</small></address>
</div><!-- doc-content -->
</body>
</html>
